<template>
  <div class="item2-box" id="unit-exbits" :class="{ 'step2-box-no': proStore.modelIndex }">
    <div class="item2-box-left">
      <div class="item2-box-left-exhibit">
        <div class="title1">展品</div>
        <div
          class="title2"
          :class="{ 'chang-item-active': auxiliaryList[0]?.id == parmas.moduleId }"
          @click="clickGroup(auxiliaryList[0].id)"
        >
          全部展品({{ auxiliaryList[0]?.total }})
        </div>
        <div
          class="title3"
          :class="{ 'chang-item-active': auxiliaryList[1]?.id == parmas.moduleId }"
          @click="clickGroup(auxiliaryList[1].id)"
        >
          未关联辅助信息的展品({{ auxiliaryList[1]?.total }})
        </div>
      </div>
      <div class="item2-box-left-heard">
        <div class="item2-box-left-heard-left">
          <span>单元辅助信息</span>
          <t-popup
            attach="#plan-child-id-2"
            overlayClassName="addAuxiIcon"
            class="placement"
            content="添加单元辅助信息，能够更好的表达单元所讲述的内容，如表格、图版、说明牌等内容。辅助信息可以关联展品，形成小组的形式展示于模板中。"
            placement="top"
            showArrow
            destroyOnClose
            trigger="hover"
          >
            <i class="doorIcon">&#xe635;</i>
          </t-popup>
        </div>
        <t-popup
          attach="#menu-left-btn-xe661"
          overlayClassName="popup"
          class="placement"
          content="新建辅助信息"
          placement="top"
          showArrow
          destroyOnClose
        >
          <div class="item2-box-left-heard-right" @click="addAuxiliart">
            <i class="doorIcon">&#xe662;</i>
          </div>
        </t-popup>
      </div>

      <draggable
        :list="auxiliaryList.slice(2)"
        :animation="100"
        item-key="id"
        class="card-item-parent-box"
        :forceFallback="true"
        ghost-class="ghost"
        @change="onMoveCallback"
        v-if="auxiliaryList.length > 2"
      >
        <template #item="{ element }">
          <div class="card-item-parent">
            <div
              @click="clickGroup(element.id)"
              class="card-item hw-flex-style-c-c hw-click-cursor"
              :class="{
                'card-item-active': element.id == parmas.moduleId,
              }"
            >
              <div class="auxiliary-left">
                <img
                  v-if="element.coverUrl"
                  class="card-item-left-img t-image t-image--fit-contain t-image--position-center"
                  :src="$filters.getLinkUrl(element.coverUrl, '?imageView2/2/w/120/h/120/format/webp')"
                  alt=""
                />
                <div v-else class="no-image">暂无图片</div>
              </div>
              <div>
                <div class="card-item-left" v-if="element.name.length < 8">{{ element.name }}</div>
                <!-- <t-popup
                  v-else
                  attach="#three3-boxs"
                  overlayClassName="popup"
                  class="placement top"
                  :content="element.name"
                  placement="top"
                  showArrow
                  destroyOnClose
                > -->
                <t-tooltip :content="element.name" v-else>
                  <div class="card-item-left">{{ element.name }}</div>
                </t-tooltip>
                <!-- </t-popup> -->
                <div class="card-item-rights">展品数量({{ element.total }})</div>
                <div class="Audio-box">
                  <img :src="publicUrls + 'assets/img/auxi-audio.svg'" alt="" v-if="element.isAudio" />
                  <img :src="publicUrls + 'assets/img/auxi-video.svg'" alt="" v-if="element.isVideo" />
                </div>
              </div>
              <div style="display: flex">
                <t-popup
                  placement="right-top"
                  overlay-class-name="editMenu-operation"
                  trigger="hover"
                  :delay="10"
                  attach="#unit-exbits"
                >
                  <div class="editMenu">
                    <i class="doorIcon">&#xe667;</i>
                  </div>

                  <template #content>
                    <div class="editMenu-level">
                      <div class="editMenu-level-item" @click.stop="editInfo(element.id, 2)">
                        <i class="doorIcon">&#xe65d;</i>
                        <span class="editMenu-level-item-left-title">编辑</span>
                      </div>
                      <div class="editMenu-level-item" @click.stop="delInfo(element.id)">
                        <i class="doorIcon">&#xe634;</i>
                        <span class="editMenu-level-item-left-title">删除</span>
                      </div>
                      <div class="editMenu-level-item" @click.stop="editInfo(element.id, 4)">
                        <img :src="publicUrls + 'assets/img/move.svg'" alt="" />
                        <span class="editMenu-level-item-left-title">移动</span>
                      </div>
                      <div class="editMenu-level-item" @click.stop="editInfo(element.id, 3)">
                        <i class="doorIcon">&#xe630;</i>
                        <span class="editMenu-level-item-left-title">查看</span>
                      </div>
                      <!-- <div class="editMenu-level-item" v-if="index !== 1" @click.stop="moveTopAx(element.id, index)">
                        <i class="doorIcon">&#xe63e;</i>
                        <span class="editMenu-level-item-left-title">上移</span>
                      </div>
                      <div class="editMenu-level-item" @click.stop="moveBottomAx(element.id, index)">
                        <i class="doorIcon">&#xe63a;</i>
                        <span class="editMenu-level-item-left-title">下移</span>
                      </div> -->
                    </div>
                  </template>
                </t-popup>
              </div>
            </div>
          </div>
        </template>
      </draggable>
    </div>
    <div class="item2-box-right">
      <div class="heard-menu">
        <div class="heard-menu-left">
          <div class="menu-left-btn menu-left-btn1" @click="addExbitShow" v-if="!proStore.isActivitys">
            <i class="doorIcon doorIconLeft">&#xe654;</i>
            <span>录入展品</span>
          </div>

          <div class="menu-left-btn menu-left-btn2" id="menu-left-btn-byId">
            <t-popup
              attach="#menu-left-btn-byId"
              overlayClassName="popup"
              class="placement bottom"
              content=""
              placement="bottom"
              showArrow
              destroyOnClose
            >
              <template #content>
                <div v-for="(item, index) in selectExbtion" :key="item.id">
                  <div class="select-item" @click="addaddExhibits(item.id, index)">
                    {{ item.name }}
                  </div>
                </div>
              </template>
              <i class="doorIcon doorIconLeft">&#xe65e;</i>
              <span>选择展品</span>
              <i class="doorIcon doorIconLeft">&#xe63a;</i>
            </t-popup>
          </div>

          <div class="menu-left-btn menu-left-btn3" id="menu-left-btn-xe661" @click="openAssocia">
            <t-popup
              attach="#menu-left-btn-xe661"
              overlayClassName="popup"
              class="placement"
              content="关联至辅助信息"
              placement="right"
              showArrow
              destroyOnClose
            >
              <i :class="{ 'lock-box': parentSelectModel.length == 0 }" class="doorIcon doorIconLeft">&#xe661;</i>
              <span :class="{ 'lock-box': parentSelectModel.length == 0 }">关联至</span>
            </t-popup>
          </div>
        </div>
        <div class="heard-menu-right">
          <seachInput @onEnterValue="onEnterInit" v-model="parmas.value" />

          <div class="dot-box">
            <span
              class="dot"
              v-if="
                parmas.LevelId !== 0 ||
                parmas.typeId !== 0 ||
                parmas.AgeId !== 0 ||
                parmas.companyId !== -1 ||
                parmas.IsAudio !== -1 ||
                parmas.IsExternal !== -1
              "
            ></span>
            <i class="doorIcon doorIconLeft" @click="openDre">&#xe666;</i>
          </div>
        </div>
      </div>

      <div class="table-list" :class="{ 'table-list-null': tabDatas.length === 0 }">
        <t-loading :loading="loading">
          <unitTable
            :fixedRows="[0, 0]"
            v-if="tabDatas.length > 0"
            @dimensionOpen="dimensionOpen"
            @editInfo="editInfoId"
            @setSlot="setSlot"
            @setSlotId="setSlotId"
            @fliterSlot="fliterSlot"
            ref="unitTableRef"
            @removeId="removeId"
            :right="true"
            :parmas="parmas1"
            :tabType="datas"
            :tabDatas="tabDatas"
            @addExhibit="selectExhibitArray"
          />
          <div class="list-null-box" v-else>
            <img :src="publicUrls + 'assets/img/exhibitNull.png'" alt="" />
            <span class="list-null-box-title">暂无展品，快去添加一个吧～</span>
            <div class="heard-menu-left">
              <div
                class="menu-left-btn menu-left-btn1"
                v-if="userStore.userLevel == 2 && !proStore.isActivitys"
                @click="addExbitShow"
              >
                <i class="doorIcon doorIconLeft">&#xe654;</i>
                <span>录入展品</span>
              </div>
              <!-- <span class="list-null-box-title">或</span> -->
              <div class="menu-left-btn menu-left-btn2">
                <t-popup
                  attach="#menu-left-btn-byId"
                  overlayClassName="popup"
                  class=""
                  content=""
                  placement="bottom"
                  showArrow
                  destroyOnClose
                >
                  <template #content>
                    <div v-for="(item, index) in selectExbtion" :key="item.id">
                      <div class="select-item" @click="addaddExhibits(item.id, index)">
                        {{ item.name }}
                      </div>
                    </div>
                  </template>
                  <i class="doorIcon doorIconLeft">&#xe65e;</i>
                  <span>选择展品</span>
                  <i class="doorIcon doorIconLeft">&#xe63a;</i>
                </t-popup>
              </div>
            </div>
          </div>
        </t-loading>
      </div>

      <drawer :tabType="datas" :visible="visible" @close="close" @Confirm="Confirm" />
      <div class="exbit-box">
        <t-dialog
          :loading="loading"
          :header="selectName"
          :visible="visible1"
          :confirm-on-enter="true"
          :on-cancel="closetable"
          :on-close="closetable"
          :cancelBtn="null"
          :confirmBtn="null"
        >
          <template #body>
            <addTable
              ref="addtableRef"
              v-if="visible1"
              :heardType="selectId"
              @addExhibit="addExhibitArray"
              :right="false"
              :parmas="parmas"
              :tabType="datas"
              :tabDatas="[]"
            />
          </template>
          <template #footer>
            <span class="footer-btm-num">已选 {{ selectModel.length }} 条</span>
            <t-button @click="closetable" theme="default" variant="outline">取消</t-button>
            <t-button @click="ok">确定添加</t-button>
          </template>
        </t-dialog>
      </div>
    </div>
    <messageModel
      submitText="删除"
      title="提示"
      :visible="visibleMessage"
      problem="确定删除此辅助信息？"
      message="删除后无法找回"
      @closeClick="auxiliaryclose"
      @submitClick="auxiliarysubmit"
    />
    <addExbition
      v-if="editexbitionShow"
      :visible="editexbitionShow"
      :id="editexbitionId"
      @closeMdeol="closeMdeol"
      @addSuccess="addSuccess"
    />
    <associationModel
      :visible="associaVisible"
      :ids="props.ids"
      :list="auxiliaryList"
      @close="associaClose"
      @moveClose="associaPass"
    />
    <tagModel :visible="tagShow" :id="tagId" @close="tagclose" @submit="tagsubmit" />
    <!-- v-if="tagShow" -->
  </div>
</template>
<script setup lang="ts">
// @ts-nocheck
import { projectDetail } from '@/api/project/project';
import { publicUrls } from '@/utils/minxin';
import { projectShowpieceSort, projectShowpieceSorts } from '@/api/exhibit/exhibit';
import addTable from './addTable.vue';
import associationModel from './association.vue';
import addExbition from '@/components/addExbition/addExbition.vue';
import seachInput from '@/components/seach/seach.vue';
import { SearchIcon } from 'tdesign-icons-vue-next';
import popbox from '../exhibits/popbox.vue';
import { tabListModel } from './data';
import unitTable from './table.vue';
import drawer from './drawer.vue';
import { MessagePlugin } from 'tdesign-vue-next';
import messageModel from '@/components/messageModel/index.vue';
import { treeList } from '@/api/user/user';
import { urls } from '@/utils/request/upload';
import tagModel from '@/components/tagModel/tabModel.vue';
import {
  exhibitiondatas,
  designList,
  addExhibits,
  disassociate,
  auxiliaryNumbers,
  moduleDelete,
  disableSort,
} from '@/api/desgin/desgin';
import { bindShowpieces } from '@/api/exhibit/exhibit';
import { LockOnIcon } from 'tdesign-icons-vue-next';
import { ref, computed, reactive, watch, nextTick } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { column1 } from './data';
import { showpieceRelate } from '@/api/exhibit/exhibit';
import { useSettingStore, useUserStore, useProjectStore } from '@/store';
import { storeToRefs } from 'pinia';
import draggable from 'vuedraggable';
const current = ref(0);
const unitTableRef = ref(null);
const userStore = useUserStore();
const proStore = useProjectStore();
const { auxiliaryType } = storeToRefs(proStore);
const props = defineProps({
  ids: {
    type: Number,
  },
});
const addtableRef = ref(null);
const pageSizeOptions = [
  { label: '每页 10 条', value: 10 },
  { label: '每页 20 条', value: 20 },
  { label: '每页 50 条', value: 50 },
  { label: '每页 100 条', value: 100 },
];
const selectExbtion = [
  { id: 3, name: '从本展览展品库选择' },
  { id: 2, name: '从私有库选择' },
  { id: 1, name: '从公有库选择' },
  { id: 5, name: '从我的关注选择' },
];
const tagShow = ref(false); //标注弹框开关
const tagId = ref(0); //标注弹框开关
const selectName = ref('');
const selectId = ref(1);
const associaVisible = ref(false); //关联至弹框
const editexbitionShow = ref(false); //录入展品弹框
const editexbitionId = ref(0);
const visibleMessage = ref(false); //删除辅助信息弹框
const auxiliaryList = ref([]); //辅助信息列表
const auxiliaryId = ref(0); //辅助信息id
const delauxiliary = ref(0); //删除辅助信息id
const auxiliaryCurrent = ref(-1);
const textvalue = ref('');
const loading = ref(false);
const loading1 = ref(false);
const tableLoading = ref(false);
const auxiliaryvisible = ref(false); //辅助信息弹框
const router = useRouter();
const route = useRoute();
const delId = ref(0);
const popVisible = ref(false);
const tabValue = ref(1);
const selectModel = ref([]);
const parentSelectModel = ref([]); //辅助信息list列表选择
const emit = defineEmits(['addExhibit', 'setInfo']);
const total = ref(0);
const total1 = ref(0);
const visible = ref(false);
const visible1 = ref(false);
const tabDatas = ref([]);
const parmas = reactive({
  projectId: localStorage.getItem('projectId'),
  companyId: -1,
  moduleId: -1,
  typeId: 0,
  AgeId: 0,
  LevelId: 0,
  SourceId: 0,
  value: '',
  PageNo: 1,
  PageSize: 99999,
  IsAudio: -1,
  IsExternal: -1,
});
const parmas1 = reactive({
  projectId: localStorage.getItem('projectId'),
  companyId: -1,
  moduleId: 0,
  typeId: 0,
  AgeId: 0,
  LevelId: 0,
  SourceId: 0,
  value: '',
  PageNo: 1,
  PageSize: 20,
});

const datas = reactive({
  select1: [], //级别
  select2: [], //来源
  select3: [], //类型
  select4: [], //年代
});

watch(
  () => props.ids,
  () => {
    parentSelectModel.value = [];
    if (tabDatas.length > 0) {
      unitTableRef.value.clearList();
    }

    if (props.ids) {
      parmas.value = '';
      // console.log('gengx');

      auxiliartInit();
      init();
    }
  },
  { deep: true },
);
watch(
  () => parmas.moduleId,
  () => {
    parentSelectModel.value = [];
    if (tabDatas.length > 0) {
      unitTableRef.value.clearList();
    }
  },
  { deep: true },
);

watch(
  () => auxiliaryType,
  () => {
    auxiliartInit();
  },
  { deep: true },
);

const fliterSlot = () => {
  nextTick(() => {
    tabDatas.value.forEach((el) => {
      if (el.sort > 9999) {
        console.log(el.sort);
        el.sort = 9999;
      }
    });
  });
};
const auxiliartInit = async () => {
  try {
    let res = await auxiliaryNumbers(localStorage.getItem('projectId'), props.ids);

    nextTick(() => {
      auxiliaryList.value = res.data;
      parmas.moduleId = -1;
      clickGroup(auxiliaryList.value[0].id);
    });
    console.log('auxiliaryList', res.data, props.ids);
  } catch {}
};
const initName = async () => {
  try {
    let res = await projectDetail(localStorage.getItem('projectId'));
    // alert(res.data.subTitle);

    proStore.isActivitys = res.data.activityId ? true : false;
  } catch {}
};
initName();
const initSelect = async () => {
  //初始化所有下拉选项
  treeList(371994471206981).then((res) => {
    datas.select1 = res.data;
  }); //级别
  treeList(371996102197317).then((res1) => {
    datas.select2 = res1.data;
  }); //来源
  treeList(371999507447877).then((res2) => {
    datas.select3 = res2.data;
  }); //类型
  treeList(372051821408325).then((res3) => {
    datas.select4 = res3.data;
  }); //年代
};

const initModel = async () => {};
const init = async () => {
  try {
    loading.value = true;
    // parmas.moduleId = props.ids;
    let { data } = await exhibitiondatas(parmas, props.ids);
    console.log(data);
    // total.value = data.total;
    data.forEach((el) => {
      el.lock = false;
    });
    tabDatas.value = data;

    loading.value = false;
  } catch (err) {
    console.log(err);
    loading.value = false;
  }
};
const setSlot = (e) => {
  let indexs = tabDatas.value.findIndex((el) => {
    return el.id === e;
  });
  // console.log(indexs);
  tabDatas.value[indexs].lock = true;
};
const setSlotId = (slot) => {
  // let indexs = tabDatas.value.findIndex((el) => {
  //   return el.id === e;
  // });
  // // console.log(indexs);
  // tabDatas.value[indexs].lock = false;
  // projectShowpieceSort(localStorage.getItem('projectId'), e, slot).then((res) => {
  //   if (res.statusCode == 200) {
  //     MessagePlugin.success('排序成功');
  //     init();
  //   }
  // });
  projectShowpieceSorts(localStorage.getItem('projectId'), slot).then((res) => {
    if (res.statusCode == 200) {
      MessagePlugin.success('排序成功');
      init();
    }
  });
};
const removeId = async (e) => {
  try {
    if (loading.value) {
      return;
    }
    loading.value = true;
    let res = await disassociate(localStorage.getItem('projectId'), e);
    MessagePlugin.success('移除成功');
    init();
    auxiliartInit();
    loading.value = false;
  } catch {
    loading.value = false;
  }
  //移除展品
};
const addExhibitArray = (e: any) => {
  selectModel.value = e;
};
const selectExhibitArray = (e: any) => {
  parentSelectModel.value = e;
  console.log(parentSelectModel.value);
};
const addaddExhibits = (id: number, index: number) => {
  if (id == 5 && userStore.VipLevel === 0 && !proStore.isActivitys) {
    MessagePlugin.warning('免费会员无法使用关注展品，详情查看会员等级');
    return;
  }
  selectId.value = id;
  selectName.value = selectExbtion[index].name;
  visible1.value = true;

  proStore.setModelIndex(true);
};
const onChange = (pageInfo) => {};
const onPageSizeChange = (size) => {
  init();
};
const onCurrentChange = (index, pageInfo) => {
  //分页事件
  init();
};
const openDre = () => {
  visible.value = true;
  proStore.setModelIndex(true);
};
const clickGroup = (e: number) => {
  console.log(e);
  parmas.moduleId = e;
  parmas.value = '';
  init();
};
const popClose = () => {
  popVisible.value = false;
}; //浮动选择(取消)

const close = () => {
  visible.value = false;
  setTimeout(() => {
    proStore.setModelIndex(false);
  }, 200);
};
const Confirm = (info: any) => {
  console.log(info);
  parmas.typeId = info.typeId ? info.typeId : 0;
  parmas.AgeId = info.AgeId ? info.AgeId : 0;
  parmas.LevelId = info.LevelId ? info.LevelId : 0;
  parmas.IsAudio = info.IsAudio ? info.IsAudio : -1;
  parmas.IsExternal = info.IsExternal ? info.IsExternal : -1;
  visible.value = false;
  init();
  setTimeout(() => {
    proStore.setModelIndex(false);
  }, 200);
};
const ok = async () => {
  try {
    if (loading.value) {
      return;
    }
    if (selectModel.value.length > 0) {
      loading.value = true;
      let res = await addExhibits(
        localStorage.getItem('projectId'),
        parmas.moduleId > 0 ? parmas.moduleId : props.ids,
        selectModel.value,
      );
      if (res.data && res.succeeded) {
        MessagePlugin.success('添加成功' + res.data + '条数据');
      } else {
        loading.value = false;
        return;
      }

      init();
      auxiliartInit();
      loading.value = false;

      // visible1.value = false;
      addtableRef.value.clearList();
      popVisible.value = false;
      // proStore.setModelIndex(false);
      textvalue.value = '';
      selectModel.value = [];

      // 455196062429253;
    } else {
      MessagePlugin.error('请选择展品');

      return;
    }
  } catch {
    loading.value = false;
    console.log('cuowu');
  }
};

const addAuxiliart = () => {
  //新建辅助信息
  proStore.setAuxiliaryId(0);
  proStore.setAuxiliaryvisible(true);
  proStore.setAuxiliaryTitleType(1);
};
const onEnterInit = () => {
  init();
};
const editInfo = (e: number, type: number) => {
  //新建辅助信息
  proStore.setAuxiliaryId(e);
  proStore.setAuxiliaryvisible(true);
  proStore.setAuxiliaryTitleType(type);
};

const delInfo = (e: number) => {
  delauxiliary.value = e;
  visibleMessage.value = true;
  proStore.setModelIndex(true);
};
const auxiliaryclose = () => {
  //删除辅助信息弹框
  visibleMessage.value = false;
  setTimeout(() => {
    proStore.setModelIndex(false);
  }, 200);
};
const auxiliarysubmit = () => {
  //删除确认
  if (loading.value) {
    return;
  }
  loading.value = true;
  moduleDelete(localStorage.getItem('projectId'), delauxiliary.value).then((res: any) => {
    if (res.statusCode == 200) {
      MessagePlugin.success(`删除成功`);
    }
    auxiliartInit();
    visibleMessage.value = false;
    loading.value = false;
    setTimeout(() => {
      proStore.setModelIndex(false);
    }, 200);
  });
};
const moveTopAx = (id: number, newIndex: number, oldIndex: number) => {
  // if (index === 1) {
  //   return;
  // }
  let newList = auxiliaryList.value.slice(2);
  let oldId = newList[oldIndex].id; //排序前id
  let newId = newList[newIndex].id; //即将替换的id
  let arr = [];
  newList.forEach((el, indexs) => {
    arr.push(el.id);
  });
  arr[oldIndex] = newId;
  arr[newIndex] = oldId;
  // arr.shift();
  // arr.pop();
  // arr.unshift(auxiliaryList.value[0].id, auxiliaryList.value[1].id);
  console.log(arr);

  updataSort(props.ids, arr);
};
const moveBottomAx = (id: number, index: number) => {
  if (index === auxiliaryList.value.length - 2) {
    return;
  }
  let oldId = auxiliaryList.value[index].id; //排序前id
  let newId = auxiliaryList.value[index + 1].id; //即将替换的id
  let arr = [];
  auxiliaryList.value.forEach((el, indexs) => {
    arr.push(el.id);
  });
  arr[index] = newId;
  arr[index + 1] = oldId;
  arr.shift();
  arr.pop();
  updataSort(props.ids, arr);
};
const updataSort = async (parentId, sort) => {
  try {
    let res = await disableSort(localStorage.getItem('projectId'), parentId, sort);
    if (res.statusCode == 200) {
      auxiliartInit();
    }
  } catch {}
};
const onMoveCallback = (val) => {
  // console.log(val.moved.element.id);
  moveTopAx(val.moved.element.id, val.moved.newIndex, val.moved.oldIndex);
  console.log('拖动前的索引 :' + val.moved.newIndex);
  console.log('拖动后的索引 :' + val.moved.oldIndex);
};
const addExbitShow = () => {
  //打开添加弹框
  proStore.setModelIndex(true);
  editexbitionId.value = 0;
  editexbitionShow.value = true;
};
const dimensionOpen = (id: number) => {
  //进行标注回调
  tagShow.value = true;
  tagId.value = id;
  proStore.setModelIndex(true);
};
const tagclose = () => {
  //标注取消回调
  console.log('触发取消回调');
  tagShow.value = false;
  setTimeout(() => {
    proStore.setModelIndex(false);
  }, 200);
};
const tagsubmit = () => {
  //标注成功回调
  tagShow.value = false;
  setTimeout(() => {
    proStore.setModelIndex(false);
  }, 200);
};
const editInfoId = (e: number) => {
  proStore.setModelIndex(true);
  editexbitionId.value = e;
  editexbitionShow.value = true;
};
const closeMdeol = () => {
  //展品添加弹框关闭
  editexbitionShow.value = false;
  setTimeout(() => {
    proStore.setModelIndex(false);
  }, 200);
};
const addSuccess = async (id: number, type?: number) => {
  try {
    if (type) {
      editexbitionShow.value = false;
      setTimeout(() => {
        proStore.setModelIndex(false);
      }, 200);
    } else {
      if (loading.value) {
        return;
      }

      loading.value = true;

      let res = await addExhibits(
        localStorage.getItem('projectId'),
        parmas.moduleId > 0 ? parmas.moduleId : props.ids,
        [id],
      );
      // MessagePlugin.success('添加成功' + res.data + '条数据');
      init();
      auxiliartInit();

      loading.value = false;
      editexbitionShow.value = false;
      setTimeout(() => {
        proStore.setModelIndex(false);
      }, 200);
    }
  } catch (err) {
    console.log(err);
    loading.value = false;
    editexbitionShow.value = false;
    setTimeout(() => {
      proStore.setModelIndex(false);
    }, 200);
  }
  //展品添加弹框打开
};
const openAssocia = () => {
  if (parentSelectModel.value.length === 0) {
    MessagePlugin.warning('请选择展品');
    return;
  }
  associaVisible.value = true;
  proStore.setModelIndex(true);
};
const associaClose = () => {
  //关联取消

  associaVisible.value = false;
  setTimeout(() => {
    proStore.setModelIndex(false);
  }, 200);
};
const associaPass = async (ids: number) => {
  //关联回调
  loading.value = true;

  let res = await bindShowpieces(localStorage.getItem('projectId'), props.ids, ids, parentSelectModel.value);
  MessagePlugin.success('关联成功');
  init();
  auxiliartInit();
  loading.value = false;
  associaVisible.value = false;
  setTimeout(() => {
    proStore.setModelIndex(false);
  }, 200);
};
const closetable = (context?: any): void => {
  visible1.value = false;
  popVisible.value = false;
  selectModel.value = [];
  setTimeout(() => {
    proStore.setModelIndex(false);
  }, 200);
};

init();
initSelect();
auxiliartInit();
</script>

<style lang="less" scoped>
@import './unitItemcss.less';
:deep(.t-dialog__ctx.t-dialog__ctx--fixed) {
  z-index: 9999;
}
.lock-box {
  opacity: 0.5;
}
.exbit-box {
  z-index: 10280 !important;
  // transform: translateZ(1px);
  :deep(.t-dialog__header) {
    height: 60px;
    box-shadow: none;
  }
}
:deep(.t-drawer) {
  z-index: 66666 !important;
}

#menu-left-btn-byId {
  .t-popup {
  }
  :deep(.t-popup__content) {
    padding: 0px !important;
    overflow: hidden;
    border-radius: 6px;
    background: #fff !important;
    margin-left: 56px;
  }
}
.list-null-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-top: 120px;
  img {
    width: 200px;
    height: 200px;
    margin-top: 16px;
  }
  .list-null-box-title {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.38);
    margin-top: 16px;
  }
  .menu-left-btn {
    margin-top: 16px;
  }
}
.table-list {
  :deep(#menu-left-btn-xe920) {
    min-height: calc(100vh - 220px) !important;
  }
  :deep(.t-table__content) {
    min-height: calc(100vh - 220px) !important;
  }
  // :deep(.t-loading__parent) {
  //   min-height: 100%;
  // }
  :deep(.t-table__content) {
  }
}
.table-list-null {
  overflow: hidden;
}
#unit-exbits {
  :deep(.editMenu-operation .t-popup__content) {
    background-color: #fff !important;
    padding: 0px !important;
  }
}
.dot-box {
  position: relative;
}
.dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e62b17;
}
:deep(.t-table--column-fixed .t-table__cell--fixed-right-first::after) {
  border-color: #f0f0f0;
}
</style>
